<%@ page import="com.pyrsana.faith.membership.User"%>
<r:require modules="form" />

<fieldset class="fields">
	<legend>Account</legend>
	<div class="fieldcontain ${hasErrors(bean: userInstance, field: 'username', 'error')} required">
		<label for="username">
			<g:message code="user.username.label" default="Username" /> <span class="required-indicator">*</span>
		</label>
		<g:textField name="username" required="" value="${userInstance?.username}" />
	</div>
	
	<div class="fieldcontain ${hasErrors(bean: userInstance, field: 'password', 'error')} required">
		<label for="password">
			<g:message code="user.password.label" default="Password" />
			<g:if test="${userInstance?.id == null }">
				<span class="required-indicator">*</span>
			</g:if>
		</label>
		<g:if test="${userInstance?.id == null }">
			<g:passwordField name="password" required="" />
		</g:if>
		<g:else>
			<g:passwordField name="password" />
		</g:else>
	</div>
</fieldset>

<sec:ifAnyGranted roles="ROLE_DIRECTOR, ROLE_ADMIN">
	<fieldset class="fields">
		<legend>Account Status</legend>
		<div
			class="fieldcontain ${hasErrors(bean: userInstance, field: 'accountExpired', 'error')} ">
			<label for="accountExpired">
				<g:message code="user.accountExpired.label" default="Account Expired" />
			</label>
			<g:checkBox name="accountExpired" value="${userInstance?.accountExpired}" />
		</div>
		
		<div
			class="fieldcontain ${hasErrors(bean: userInstance, field: 'accountLocked', 'error')} ">
			<label for="accountLocked">
				<g:message code="user.accountLocked.label" default="Account Locked" />
			</label>
			<g:checkBox name="accountLocked" value="${userInstance?.accountLocked}" />
		</div>
		
		<div
			class="fieldcontain ${hasErrors(bean: userInstance, field: 'enabled', 'error')} ">
			<label for="enabled">
				<g:message code="user.enabled.label" default="Enabled" />
			</label>
			<g:checkBox name="enabled" value="${userInstance?.enabled}" />
		</div>
		
		<div
			class="fieldcontain ${hasErrors(bean: userInstance, field: 'passwordExpired', 'error')} ">
			<label for="passwordExpired">
				<g:message code="user.passwordExpired.label" default="Password Expired" />
			</label>
			<g:checkBox name="passwordExpired" value="${userInstance?.passwordExpired}" />
		</div>
	</fieldset>
</sec:ifAnyGranted>